// pages/02admin/00shop/shopSet.js
var app = getApp()
var appData = getApp().globalData
Page({
    data: {
        shopInfo: '',
    },

    onLoad: function (opt) {
        console.log('appData', appData)
        this.setData({
            shopInfo: appData.shopInfo.shopInfo,
            userInfo: appData.guestInfo
        })
        this.unFocus();
    },

    unFocus: function () {
        this.setData({
            seatFeeSet: 0,
            telSet: 0,
            nameSet: 0
        })
    },

    setTel: function () {
        if (appData.loginMode == 'boss') {
            this.setData({
                seatFeeSet: 0,
                telSet: 1,
                nameSet: 0
            })
        } else {
            app.toast('掌柜登录才能操作')
        }

    },

    setSeatFee: function () {
        if (appData.loginMode == 'boss') {
            this.setData({
                seatFeeSet: 1,
                telSet: 0,
                nameSet: 0
            })
        } else {
            app.toast('掌柜登录才能操作')
        }
    },

    setName: function () {
        if (appData.loginMode == 'boss') {
            this.setData({
                seatFeeSet: 0,
                telSet: 0,
                nameSet: 1
            })
        } else {
            app.toast('掌柜登录才能操作')
        }
    },

    submitShop: function (e) {
        var param = e.detail.value
        param.uid = appData.shopInfo.userid
        var that = this
        app.getJsonData('api/admin/my_set.php', param, function (res) {
            that.unFocus()
            if (param.seat_fee) {
                appData.shopInfo.shopInfo.seat_fee = param.seat_fee
            }
            if (param.name) {
                appData.shopInfo.shopInfo.name = param.name
            }
            if (param.tel) {
                appData.shopInfo.shopInfo.tel = param.tel
            }
            that.setData({ shopInfo: appData.shopInfo.shopInfo })
        })
    },
})